package com.jdbc.tool;

import java.io.IOException;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;


public class DBLianjie {
   public static String dbUser="";
   public static String dbPassword="";
   public static String dbUrl="";
   public static String dbDriver="";
   
   static{
	   Properties prop=new Properties();
		try {
			prop.load(DBLianjie.class.getResourceAsStream("/jdbc.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		dbUrl=prop.getProperty("dbUrl");
		dbDriver=prop.getProperty("dbDriver");
		dbUser=prop.getProperty("dbUser");
		dbPassword=prop.getProperty("dbPassword");
		
		try {
			Class.forName(dbDriver);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
   }
   public static Connection getconn(){
	   Connection conn=null;
	   try {
		conn=DriverManager.getConnection(dbUrl,dbUser,dbPassword);
	} catch (SQLException e) {
		e.printStackTrace();
	}
	   
	   return conn;
   }
   
}
